////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __WN_LVALUE_H__
#define __WN_LVALUE_H__

// This is included because of a bug in VS2008 (It generated the wrong vtable size for WNScriptingEngine)
// IT does not need to be included otherwise

#include "WNCore/inc/WNBase.h"

#if defined _WN_WINDOWS && _WN_MSVC < 160000000
    #include "WNScripting/inc/WNScriptingEnginePublic.h"
#endif

#include "WNScripting/inc/WNParseNode.h"

enum WNLValueType {
    eWNLValueIdentifier,
    eWNLValueArrayAccess,
    eWNLValueStructAccess,
    eWNLValueInvalid
};

class WNExpression;

class WNLValue : public WNParseNode {
public:
    
    WNLValue(WN_SIZE_T _startLine,
             WN_SIZE_T _endLine,
             WN_SIZE_T _startChar,
             WN_SIZE_T _endChar,
             WNIdentifierElement _identifier);

    WNLValue(WN_SIZE_T _startLine,
             WN_SIZE_T _endLine,
             WN_SIZE_T _startChar,
             WN_SIZE_T _endChar,
             WNLValue* _lval,
             WNExpression* _expr);

    WNLValue(WN_SIZE_T _startLine,
             WN_SIZE_T _endLine,
             WN_SIZE_T _startChar,
             WN_SIZE_T _endChar,
             WNLValue* _lVal,
             WNIdentifierElement _identifier);


    virtual ~WNLValue();
    virtual llvm::Value* OptimizeAndGenerate(WNScriptingEngineData& _scriptingData, WNFunctionDecl* _functionDecl);
    WNTypeElement GetOutType();

private:
    WNIdentifierElement mIdentifier;
    WNLValue* mLValue;
    WNExpression* mExpression;
    WNLValueType mType;
    WNTypeElement mOutType;
};

#endif // __WN_LVALUE_H__